<!DOCTYPE html>
<html>
    <!--头文件-->
    {include file='head'}


<section class="rt_wrap content mCustomScrollbar">
    <div class="rt_content">

        <!--打印开始处-->
        <!--startprint-->
        <div class="page_title">
            <h2 class="fl">订单详情信息</h2>
        </div>
        <table class="table">
            <tr>
                <td>订单编号：<a>{$order['order_card']}</a></td>
                <td>收件人：{$receive['receive_name']}</td>
                <td>联系电话：{$receive['receive_phone']}</td>
                <td>收件地址：{$receive['all_place']}{$receive['detail_address']}</td>
            </tr>
            <tr>
                <td>订单状态：<a>{$order['is_pay']}，{$order['order_status']}</a></td>
                <td colspan="3">订单备注：<mark>{$order['order_desc']}</mark></td>
            </tr>
            <tr>
                <td>下单时间：{$order['update_time']}</td>
                <td>付款时间：{$order['pay_time']}</td>
                <td>确认时间：{$order['succ_time']}</td>
                <td>评价时间时间：---</td>
            </tr>
        </table>
        <table class="table">

            {for start="0" end="count($detail)" as name="i"}

            <tr>

                <td class="center"><img src="{$webSite}{$good[$i]['small_logo']}" width="50" height="50"/></td>
                <td>{$good[$i]['goods_name']}</td>
                <td class="center">{$good[$i]['goods_card']}</td>


                <td class="center"><strong class="rmb_icon">{$detail[$i]['last_paid']}</strong></td>
                <td class="center">

                        <!--使得商品和属性,品牌,分类一一对应,因为属性,品牌,分类可能一样-->

                        <p>分类：{$type[$i]['type_name']}</p>



                        <p>品牌：{$brand[$i]['brand_name']}</p>

                        <p>口味：{$attr[$i]['attr_name']}</p>


                </td>
                <td class="center"><strong>{$detail[$i]['buy_num']}</strong></td>
                <td class="center"><strong class="rmb_icon">{$detail[$i]['last_paid'] * $detail[$i]['buy_num']}</strong></td>
                <td class="center">件</td>
            </tr>

            {/for}

        </table>
        <!--打印结束处-->
        <!--endprint-->

        <aside class="mtb" style="text-align:right;">

            <label>管理员操作：</label>
            <input type="text" class="textbox textbox_295" placeholder="管理员操作备注"/>
            <input type="button" value="打印订单" class="group_btn" id="print"/>
            {if $order['is_pay'] !== '已付款'}
            <input type="button" value="付款" class="group_btn" id="pay" payBtn="{$order['order_id']}"/>
            {/if}

        {if $order['is_pay'] == '已付款'}
            {if $order['order_status'] == '待配货'}
            <input type="button" value="配货" class="group_btn" id="collocate" collBtn="{$order['order_id']}"/>
            {/if}

            {if in_array($order['order_status'],['0'=>'待配货', 1=>'已配货(待发)', 2=>'已发货(运送中)', 3=>'已送达(未签收)'])}
            <input type="button" value="发货" class="group_btn" id="post" postBtn="{$order['order_id']}"/>
            {/if}

            {if in_array($order['order_status'],['0'=>'待配货', 1=>'已配货(待发)', 2=>'已发货(运送中)', 3=>'已送达(未签收)'])}
            <input type="button" value="确认收货" class="group_btn" id="sureRece" receBtn="{$order['order_id']}"/>
            {/if}
        {/if}
        </aside>
    </div>
</section>
</body>
</html>
<script>

    //打印
    $(function(){

        //点击打印订单详情
        $('#print').click(function () {

            var bdhtml=window.document.body.innerHTML;//获取当前页的html代码
            var startStr="<!--startprint-->";//设置打印开始区域
            var endStr="<!--endprint-->";//设置打印结束区域
            var printHtml=bdhtml.substring(bdhtml.indexOf(startStr)+startStr.length,bdhtml.indexOf(endStr));//从标记里获取需要打印的页面
            window.document.body.innerHTML=printHtml;//需要打印的页面
            window.print();
            window.document.body.innerHTML=bdhtml;//还原界面
            location.reload();

        });

        //付款
        $('#pay').click(function () {

            var $pay = $(this).attr('payBtn');
            $.post('orderStatus',{oid:$pay,pay:1},success,'json');
        });

        //配货
        $('#collocate').click(function () {

            var $coll = $(this).attr('collBtn');
            $.post('orderStatus',{oid:$coll,status:1},success,'json');
        });

        //发货
        $('#post').click(function () {

            var $post = $(this).attr('postBtn');
            $.post('orderStatus',{oid:$post, status:2},success,'json');
        });

        //确认收货
        $('#sureRece').click(function () {

            var $rece = $(this).attr('receBtn');
            $.post('orderStatus',{oid:$rece, status:4},success,'json');
        });


        //回调函数
        function success(data)
        {
            console.log(data);

            switch (data.state) {
                case 1:
                    alert(data.tip);
                    break;
                case 2:
                    alert(data.tip);
                    break;
            }
            //重载当前页面
            window.location.reload();
        }
    });



</script>
